package com.example.infomanagesystem.common;

import lombok.Data;

import java.util.List;

@Data
public class Page<T> {
    private int currentPage; // 当前页码
    private int pageSize;// 每页大小
    private int totalPages;
    private long total;      // 总记录数
    private List<T> records; // 当前页数据

    public Page(int currentPage, int pageSize, long total, List<T> records) {
        this.currentPage = currentPage;
        this.pageSize = pageSize;
        this.total = total;
        this.records = records;
        this.totalPages = getTotalPages();
    }

    // 计算总页数
    public int getTotalPages() {
        return (int) Math.ceil((double) total / pageSize);
    }
}